package com.test.design.pattern.command;

import java.util.Map;
import java.util.Set;

/**
 * @ClasName OrderCommand
 * @Descripution TODO 具体的命令类
 * @Author leikw
 * @Date 2021/12/21 9:16
 * @Version V1.0
 */
public class OrderCommand implements Command {

    //持有接收者对象
    private SeniorChef receiver;
    private Order order;

    public OrderCommand(SeniorChef receiver, Order order) {
        this.receiver = receiver;
        this.order = order;
    }

    public void execute() {
        System.out.println(order.getDiningTable()+"桌的订单：");
        Map<String, Integer> foodDir = order.getFoodDir();
        //遍历map
        Set<String> foodNames = foodDir.keySet();

        for (String foodName : foodNames) {
            receiver.makeFood(foodName,foodDir.get(foodName));
        }
        System.out.println(order.getDiningTable() + "桌的饭准备完毕！！！");
    }

}
